var base; //根路径

$(document).ready(function () {
	// 为全局变量base赋值
	if( isNull(base) ){
		base = getRootPath();
	}
	//为订单表添加鼠标经过变色功能
    $(".order tr").mouseover(function () {
		if(  contains( this.id , 'order_')   ){
		   //如果鼠标移到class为stripe的表格的tr上时，执行函数  
       		 $(this).addClass("over");
		}  
       
    }).mouseout(function () {
        if(  contains( this.id , 'order_')   ){
		   //给这行添加class值为over，并且当鼠标一出该行时执行函数  
       		 $(this).removeClass("over");
		} 
    })
    
   
});


var showOrderIterm = function( orderId){
	 
	 var order =  document.getElementById("order_"+orderId); //订单
	 var orderItemTr =  document.getElementById("orderItem_" + orderId); //订单项
	 var img = order.children[0].children[0];
	 if(img){
		 if( contains(img.currentSrc,'+.png') ){ // 如果订单图片为+,则显示订单项
			 orderItemTr.style.display = 'table-row';
			 img.src = base + "/resources/img/admin/orderManagement/-.png";
		 }else{  // 如果订单图片为-,则隐藏订单项
			 orderItemTr.style.display = 'none'; 
			 img.src = base + "/resources/img/admin/orderManagement/+.png";
		 }
	 }
	
 }
 /**
   source字符串是否包含target字符串
   包含返回 true
   否则返回 false
 */
 var contains = function(source,target){
	 if(  !isNull(source) &&  !isNull(target) ){
		if( source.indexOf(target) != -1 ){
			return true;
		}
	 }
	 return false;
 }
 
 /**
   字符串为空或者未定义
 */
 var isNull = function(target){
	 if(target==null || target == undefined ){
		  return true;
	 }
	 return false;
 }
 /**
  * 获得根路径
  * */
 function getRootPath() {
     var strFullPath = window.document.location.href;  
     var strPath = window.document.location.pathname;  
     var pos = strFullPath.indexOf(strPath);  
     var prePath = strFullPath.substring(0, pos);  
     var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);  
     var rootPath = prePath + postPath;  
     return (rootPath);  
 }  
 